package com.netcracker.studies;

import Bank.Account;
import Bank.Transaction;
import Beans.AuthorizationBean;
import DBConnection.DBAPI;
import org.apache.log4j.Logger;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

@WebServlet(name = "GetTransactions")
public class GetTransactions extends BaseServlet {

    private static final Logger log = Logger.getLogger(GetTransactions.class);

    protected void handlePostRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {



    }

    protected void handleGetRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession(true);
        if (session.getAttribute("transactions") != null)
            session.removeAttribute("transactions");
        session.setAttribute("transactions", DBAPI.getTransactionByAccount(new BigInteger(request.getParameter("id_acc"))));
        //response.getWriter().write("transaction.jsp");
        request.getRequestDispatcher("transaction.jsp").forward(request,response);
    }
}
